package study03;

public class Java02_zdy_error {
    public static void main(String[] args) {
//        login("zc", "admin");
        try {
            login("admin", "admin");
        } catch (AccountException e) {
            System.out.println(e + "请确认");
        } catch (PasswordException e) {
            System.out.println(e + "请确认");
        } catch (LoginException e) {
            System.out.println(e + "网络错误");
        }
    }

    public static void login(String account, String password) {
        if (!"admin".equals(account)) {
            throw new AccountException("账户输入有误");
        }
        if (!"admin".equals(password)) {
            throw new PasswordException("密码输入有误");
        }
        System.out.println("登陆成功");
    }
}

class AccountException extends LoginException {
    public AccountException(String message) {
        super(message);
    }
}

class PasswordException extends LoginException {
    public PasswordException(String message) {
        super(message);
    }
}

//  自定义异常
class LoginException extends RuntimeException {
    public LoginException(String message) {
        super(message);
    }
}
